﻿<div ng-controller="ClientManager_PaymentInfoListC">
    <div class="bg-light lter b-b wrapper-md">
        <h3 class="m-n font-thin h3">我的报款</h3>
    </div>
    <div class="bg-light lter b-b wrapper-md">
        <div class="row">
            <div class="col-xs-12 input-group" style="padding: 0px 15px 5px">
                <input type="text" class="form-control" id="findname" placeholder="按名称查找" ng-model="findname">
                    <span class="input-group-btn">
                        <button class="btn btn-default" type="button" ng-click="find()">查找</button>
                    </span>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-8 btn-group dropdown" dropdown>
                <button class="btn btn-default" dropdown-toggle>按状态查看 <span class="caret"></span></button>
                <ul class="dropdown-menu">
                    <li ng-click="find('')"><a href>查看全部</a></li>
                    <li ng-click="find(1)"><a href>待确认</a></li>
                    <li ng-click="find(3)"><a href>已通过</a></li>
                    <li ng-click="find(2)"><a href>驳回</a></li>
                </ul>
            </div>
            <div class="col-xs-4 btn-group">
                <button class="btn btn-default" ng-click="$state.go('app.Customer_SelfList')">选择客户户头报款</button>
            </div>
        </div>
    </div>
    <!--<div ng-repeat="item in pageData.Data">-->
        <!--<div class="list-group">-->
            <!--<a href="" class="list-group-item ">-->
                <!--<h4 class="list-group-item-heading">{{item.Customer.ShortName}}</h4>-->
                <!--<p class="list-group-item-text">户头：{{item.Account.Name}}  报款时间：{{item.CreateTime}}</p>-->
                <!--<p>报款：￥{{item.Sum}}</p>-->
                <!--<p ng-if="item.State==4">状态：未通过</p>-->
                <!--<p ng-if="item.State==3">状态：已通过</p>-->
                <!--<p ng-if="item.State==0">状态：待确认</p>-->
                <!--<p>备注：{{item.Remark}}</p>-->
            <!--</a>-->
        <!--</div>-->
    <!--</div>-->



        <div class="panel panel-default" style="margin-bottom: 10px" ng-repeat="item in pageData.Data">
            <div class="panel-heading">
                <h3 class="panel-title">{{item.Customer.Name}}</h3>
            </div>
            <div class="panel-body"> 
                <p>户头：{{item.Account.Name}}</p>
                <p ng-if="item.PaymentStatus == 1" class="list-group-item-text">退款：￥{{item.Sum | number:2}}
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <span ng-if="item.State==2">状态：驳回</span>
                    <span ng-if="item.State==3">状态：已通过</span>
                    <span ng-if="item.State==1">状态：待确认</span>
                </p>
                <p ng-if="item.PaymentStatus == 0" class="list-group-item-text">报款：￥{{item.Sum | number:2}}
                    &nbsp;&nbsp;&nbsp;&nbsp;
                <span ng-if="item.State==2">状态：驳回</span>
                <span ng-if="item.State==3">状态：已通过</span>
                <span ng-if="item.State==1">状态：待确认</span>
                </p>

                <p>备注：{{item.Remark}}</p>
                <p>审批意见：{{item.ApprovalRemark}}</p>
            </div>

            <div class="panel-footer">{{item.CreateTime}}</div>
        </div>
    <div class="row text-center">
        <div class="panel-heading" my-pagination get-page-data="getData" mypagedata="pageData"></div>
    </div>
</div>
<script>
    angular.module('app')//非标优惠
.controller("ClientManager_PaymentInfoListC", function ($scope, $state, $http,toSave) {
    $scope.pageData = {};
    $scope.pageData.Page = 0;
    $scope.state = "";
    $scope.findname = "";
    $scope.pageData.Rows = $scope.defPageRows;
    $scope.getData = function (p, r) {
        if (p) {
            p = null ? 1: p;
            p = p < 1 ? 1 : p;
        } else p = 1;
        if (r) {
        } else r = $scope.defPageRows;
        toSave.save_pages_lis(p,r);//保存当前页码和条数
       $http({
           url: "/api/ClientManager/PaymentInfo",
           method: "GET",
           params: {state:$scope.state,page:p,rows:r,customerName:$scope.findname}
       })
       .then(function (res) {
           $scope.pageData = res.data;
               console.log($scope.pageData);
           })
       .then(function (error) {
           if (error) {
               alert("数据获取失败");
           }
       });
   };
    //加载数据
    // $scope.getData(1, $scope.pageData.Rows);

    $scope.find = function (state) {
        if(state || state == ''){
            $scope.state=state;
        }
//        $scope.getData(1, $scope.pageData.Rows);
        console.log(toSave.get_pages());
        localStorage.setItem('c',$scope.state);
        toSave.save_inputs();//点击查询先保存input里面的值
        $scope.getData(1, $scope.pageData.Rows);
    };
    if (toSave.get_inputs('findname')|| localStorage.getItem('c')!= null) {
        $scope.findname=toSave.get_inputs('findname');//把保存该id名的值取出来赋值给input框
        $scope.state=localStorage.getItem('c');
//        console.log(localStorage.getItem('c'))
        $scope.getData(toSave.get_pages(), toSave.get_lis());
    }else{
        $scope.getData(toSave.get_pages(), $scope.pageData.Rows);
    }
    })
</script>
<script src="js/services/toSave.js"></script>
